package com.dsh.system.service.impl;

import com.dsh.system.dao.BannerDao;
import com.dsh.system.entity.Banner;
import com.dsh.system.entity.NoticeVo;
import com.dsh.system.service.BannerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Banner)表服务实现类
 *
 * @author makejava
 * @since 2022-05-11 16:51:32
 */
@Service("bannerService")
public class BannerServiceImpl implements BannerService {
    @Resource
    private BannerDao bannerDao;


    @Override
    public List<Banner> queryAll(int show) {
        if (show==1){
            List<Banner> banners = bannerDao.queryHomeAll();
            return banners;
        }
        if (show==2){
            List<Banner> banners = bannerDao.queryAdminAll();
            return banners;
        }
       return null;
    }

    @Override
    public Banner queryById(int id) {
        Banner banner = bannerDao.queryById(id);
        return banner;
    }

    @Override
    public int insertOne(Banner banner) {
        int i = bannerDao.insertOne(banner);
        return i;
    }

    @Override
    public int updateOne(Banner banner) {
        int i = bannerDao.updateOne(banner);
        return i;
    }

    @Override
    public int deleteOne(int id) {
        int i = bannerDao.deleteOne(id);
        return i;
    }

    @Override
    public PageInfo<NoticeVo> selectAllNotice(int limit, int page) {
        PageHelper.startPage(page,limit);
        List<NoticeVo> noticeVos = bannerDao.selectAllNotice();
        return new PageInfo<>(noticeVos);
    }

    @Override
    public int updateNotice(NoticeVo noticeVo) {
        int i = bannerDao.updateNotice(noticeVo);
        return i;
    }

    @Override
    public int insertOneNotice(NoticeVo noticeVo) {
        int i = bannerDao.insertOneNotice(noticeVo);
        return i;
    }

    @Override
    public int deleteOneNotice(int id) {
        int i = bannerDao.deleteOneNotice(id);
        return i;
    }

    @Override
    public NoticeVo selectNoticeById(int id) {
        NoticeVo noticeVo = bannerDao.selectNoticeById(id);
        return noticeVo;
    }
}